package emulator.support;

import emulator.hardware.HwByte;
import emulator.hardware.HwWord;
import emulator.util.MemoryPtr;

public class IndirectYOperandEval implements OperandEval {

	MemoryPtr instruction;
	
	public IndirectYOperandEval(MemoryPtr ptr) {
		instruction = ptr;
	}

	@Override
	public String getDetails(CpuState cpu_state) {
		int zp_addr = instruction.getByteOp();
		instruction.setAddress(zp_addr);
		int ptr = instruction.getWordOp();
		int reg_y = cpu_state.getValue("Y");
		int address = ptr+reg_y;
		instruction.setAddress(address);
		int value = instruction.getByteOp();
		return "(($"+new HwByte(zp_addr)+") + Y -> $"+new HwWord(ptr)+" + $"+new HwByte(reg_y)+" -> $"+new HwWord(address)+") -> $"+new HwByte(value);
	}

}
